package com.huaqin.customer;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;


public class ConditionManger {
	private static final String TAG ="ConditionManger";
	private List<Trigger> mTigger = null;
	
	public ConditionManger(){
		mTigger = new ArrayList<Trigger>();
	}
	
	public String getConditionDescription(){
	    int len = mTigger.size();
	    String description = "\n============================\n";
	    
        for(int i = 0; i < len; i++){
            description += mTigger.get(i).getConditionDescription();
        }
        description += "\n============================\n";
                
        return description;
	}
	
	public void addTrigger(Trigger trigger){
		mTigger.add(trigger);
	}
	
	public boolean updateAllTriggerStatus(){
		Log.v(TAG, "updateAllTriggerStatus() Trgger:" + mTigger.size());

		int len = mTigger.size();
		for(int i = 0; i < len; i++){
			if(mTigger.get(i) != null){
				if(mTigger.get(i).updateAllkCondition()){
					return true;
				}
			}
			else{
				Log.e(TAG, "mTigger get Condition is null!");
			}
		}
		
		return false;
	}
	
	public void finishAllTrigger(){
		Log.i(TAG, "finishAllTrigger()");
		
		int len = mTigger.size();
		for(int i = 0; i < len; i++){
			mTigger.get(i).finishAllCondition();
		}
	}
	
}
